package com.zywl.utils.utils.enums;

import com.zywl.utils.utils.Constants;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: xushixiang
 * @Date: 2018/11/21 23:54
 * @Description:
 */
public enum RoleLevelEnum {
    ONE(1, "一级"), TWO(2, "二级"), THREE(3, "三级"), FOUR(4, "四级");

    private final int key;
    private final String value;

    RoleLevelEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static String getValueByKey(int key) {
        for (RoleLevelEnum en : RoleLevelEnum.values()) {
            if (en.getKey() == key) {
                return en.getValue();
            }
        }
        return Constants.STRING_NULL;
    }

    public static List<Map<String, Object>> getListData() {
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        Map<String, Object> map = null;
        for (RoleLevelEnum en : RoleLevelEnum.values()) {
            map = new HashMap<String, Object>();
            map.put("key", en.getKey());
            map.put("value", en.getValue());
            list.add(map);
        }
        return list;
    }
}
